<template>
 <div>
   <h2 style="margin-left:20px">AI运动处方</h2>
    <div class="formboard" v-loading="isLoading">

    <div class="formboard-item" v-for="(item,index) in source" :key="index">
      <div class="formboard-item-topImg">
        <img :src="$store.state.user.BASE_URL + item.pic" alt="">
      </div>
      <div class="formboard-item-title">
        <span>
          {{item.title}}
        </span>
        <el-switch
          @change="changeStatus(item)"
          v-model="item.status"
          active-color="#13ce66"
          inactive-value="0"
          active-value="1"
         ></el-switch>
      </div>
      <div class="formboard-item-info">
        <span>{{item.info}}</span>
      </div>
    </div>
  </div>
   <div style="display:flex;align-items: center;justify-content: center" v-if="!!!source.length">
      <div>
        <div style="display: flex;align-items: center;justify-content: center">
          <img style="width: 400px;height: 400px;margin-top: 100px" src="../../../../assets/Ai_image/nullSource.png" />
        </div>
        <div style="margin-top: 40px">
          <span style="text-align: center;font-size: 24px;color: #409EFF">请联系学校管理员上传学生体质健康检测表，帮助智慧体育大脑激活运动处方推荐功能</span>
        </div>
      </div>
   </div>
 </div>
</template>

<script>
import  {sports_pList,changeSports} from "@/api/sports/Aplan"
export default {
  data(){
    return{
      value:true,
      source:[],
      isLoading:false

    }
  },
  created() {
    this.getSource()
  },
  methods:{
    getSource(){
      this.isLoading = true
      let data ={
        type:2,
        schoolId: this.$store.state.user.USER_INFO.pscShId,
        }
      sports_pList(data).then(response=>{
        if(response.code === 200){
          this.source = response.result;
        }else {
          this.$alert(response.message, '', {
            confirmButtonText: '关闭',

          });
        }
        this.isLoading = false
      })
    },
    changeStatus(item){
      changeSports({id:item.id,status:item.status}).then(response=>{
        if (response.code === 200) {
          this.getSource();
        }
      })
    }
  },
  watch:{
    checked:{
      immediate:true,
      handler(newVal){
        if (newVal === 1) {}
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.formboard{
  display: flex;
  flex-wrap: wrap;
}
.formboard-item{
  margin-top: 20px;
  width: calc(25% - 10px);
  margin-left: 10px;
  border: 1px solid #F1F1F1;
  border-radius: 0 8px 8px 8px;
  display: flex;
  flex-direction: column;
  padding-bottom: 15px;
  .formboard-item-topImg{
    width: 100%;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    img{
      max-width: 100%;
      max-height: 100%;
      width: auto;
      height: auto;
    }
  }
  .formboard-item-title{
    font-size: 14px;
    padding: 10px;
    box-sizing: border-box;
    color: #000000;
    display: flex;
    justify-content: space-between;
  }
  .formboard-item-info{
    font-size: 12px;
    color:#878787 ;
    padding: 3px 10px;
    box-sizing: border-box;
    line-height: 20px;
    height: 80px;
    span{
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 3;
      overflow: hidden;
    }
  }
  .formboard-item-handle{
    display: flex;
    justify-content: space-between;

    .edit{
      background:#DBEEFF ;
      color:#1890FF ;
      margin-right: 5%;
    }
    .handle{
      margin-left: 3%;
    }
    .com{
      flex: 1;
    }
  }
}

</style>
